# -*- coding: utf-8 -*-
=begin
  Copyright (C) 2011-2014 Takashi SUGA

  You may use and/or modify this file according to the license
  described in the LICENSE.txt file included in this archive.
=end

module MiniTest

  module CalendarTypes
    class Islamic < MiniTest::TestCase

      Sample = [
        ["1435-01-01", 2456602],["1435-02-01", 2456632],["1435-03-01", 2456661],["1435-04-01", 2456691],
        ["1435-05-01", 2456720],["1435-06-01", 2456750],["1435-07-01", 2456779],["1435-08-01", 2456809],
        ["1435-09-01", 2456838],["1435-10-01", 2456868],["1435-11-01", 2456897],["1435-12-01", 2456927],

        ["1436-01-01", 2456956],["1436-02-01", 2456986],["1436-03-01", 2457015],["1436-04-01", 2457045],
        ["1436-05-01", 2457074],["1436-06-01", 2457104],["1436-07-01", 2457133],["1436-08-01", 2457163],
        ["1436-09-01", 2457192],["1436-10-01", 2457222],["1436-11-01", 2457251],["1436-12-01", 2457281],

        ["1437-01-01", 2457311],["1437-02-01", 2457341],["1437-03-01", 2457370],["1437-04-01", 2457400],
        ["1437-05-01", 2457429],["1437-06-01", 2457459],["1437-07-01", 2457488],["1437-08-01", 2457518],
        ["1437-09-01", 2457547],["1437-10-01", 2457577],["1437-11-01", 2457606],["1437-12-01", 2457636],


        ["1435-01-01", 2456602],["1435-02-01", 2456631],["1435-03-01", 2456660],["1435-04-01", 2456690],
        ["1435-05-01", 2456719],["1435-06-01", 2456749],["1435-07-01", 2456778],["1435-08-01", 2456808],
        ["1435-09-01", 2456838],["1435-10-01", 2456868],["1435-11-01", 2456898],["1435-12-01", 2456927],

        ["1436-01-01", 2456956],["1436-02-01", 2456986],["1436-03-01", 2457015],["1436-04-01", 2457044],
        ["1436-05-01", 2457074],["1436-06-01", 2457103],["1436-07-01", 2457133],["1436-08-01", 2457162],
        ["1436-09-01", 2457192],["1436-10-01", 2457222],["1436-11-01", 2457251],["1436-12-01", 2457281],

        ["1437-01-01", 2457310],["1437-02-01", 2457340],["1437-03-01", 2457370],["1437-04-01", 2457399],
        ["1437-05-01", 2457429],["1437-06-01", 2457458],["1437-07-01", 2457487],["1437-08-01", 2457517],
        ["1437-09-01", 2457546],["1437-10-01", 2457576],["1437-11-01", 2457605],["1437-12-01", 2457635],
      ]

      def test_islamic_date
        sample = Sample.dup
        %w(TabularIslamic EphemerisBasedIslamic?long=140.5200E&lat=38.1560N).each do |frame|
          date = When.when?('1435-1-1', :frame=>frame)
          36.times do
            assert_equal(sample.shift, [date.to_s, date.to_i])
            date += When::P1M
          end
        end
      end
    end
  end

end
